﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WorkingTitleDungeonCrawler
{
    class GameObj
    {
        // Properties
        public Vector2 Position // the object's position
        {
            get;
            set;
        }
        public Texture2D Gfx // the object's graphics
        {
            get;
            set;
        }
        public float Angle // the angle of the object
        {
            get;
            set;
        }
        public virtual double Radius
        {
            get { return 24.0; }
            set { }
        }

        // Methods
        public virtual void Draw(SpriteBatch spritebatch, Vector2 DrawOffset)
        {
            
               spritebatch.Draw(Gfx, Position - DrawOffset + new Vector2(0, 0), null,
                    Color.White, Angle + (float)Math.PI / 2, new Vector2(Gfx.Height / 2, Gfx.Width / 2), 1.0F,
                    SpriteEffects.None, 0);
            
        }

        public bool CheckCollision(GameObj target)
        {
            bool collision;
            double xdiff = this.Position.X - target.Position.X;
            double ydiff = this.Position.Y - target.Position.Y;

            if ((xdiff * xdiff + ydiff * ydiff)  < (this.Radius + target.Radius) * (this.Radius + target.Radius))
            {
                collision = true;
            }
            else
            {
                collision = false;
            }
            return (collision);
        }
    }
}
